{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "05287f7e",
   "metadata": {},
   "source": [
    "* 日期：2022-09-21 \\ week04（周三）\n",
    "* 课程：python\n",
    "* 记录人：huangbairui"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7e093ff",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "> 1.数值(number)\n",
    ">> A.定义\n",
    ">> B.方法\n",
    "\n",
    "> 2.字符串(string)\n",
    ">> A.定义\n",
    ">> B.方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7ca8b8e8",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (4118054642.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [3]\u001b[1;36m\u001b[0m\n\u001b[1;33m    > 1. 对数值进行分类\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 1.数值\n",
    "> 1. 对数值进行分类\n",
    ">> 1. 整数(int)\n",
    ">> 2. 浮点型(float)\n",
    ">> 3. 复数 (compler)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "315ec477",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 <class 'int'>\n"
     ]
    }
   ],
   "source": [
    "# 整数\n",
    "a = 99\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6caa2cd7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99.9 <class 'float'>\n"
     ]
    }
   ],
   "source": [
    "# 浮点型\n",
    "b = 99.9\n",
    "print(b,type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5062bcdd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "198.9 <class 'float'>\n"
     ]
    }
   ],
   "source": [
    "c = a+b\n",
    "print(c,type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f9d16597",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2+3j) <class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "#  复数\n",
    "d = 2+3j\n",
    "print(d,type(d))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a87be8e8",
   "metadata": {},
   "source": [
    "## 2.字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e4f840b7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alex <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "name = \"Alex\"\n",
    "print(name,type(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ed4398e0",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can't multiply sequence by non-int of type 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m8\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m      2\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m22\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mb\u001b[49m\n",
      "\u001b[1;31mTypeError\u001b[0m: can't multiply sequence by non-int of type 'str'"
     ]
    }
   ],
   "source": [
    "a = \"8\"\n",
    "b = \"22\"\n",
    "a * b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "464e803e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "18 18\n",
      "<class 'int'> <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "a = 18\n",
    "b = \"18\"\n",
    "print(a,b)\n",
    "print(type(a),type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "ca19b9bd",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3844899037.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [12]\u001b[1;36m\u001b[0m\n\u001b[1;33m    \"doesn\" t\"\u001b[0m\n\u001b[1;37m            ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 关于单双引号\n",
    "\"doesn\" t\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "39e23d96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'doesn,t'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 解决方案1\n",
    "\"doesn,t\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0a3bbd06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'doesn\"t'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 解决方案3\n",
    "\"doesn\\\"t\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6b4caf99",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (2693316446.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [17]\u001b[1;36m\u001b[0m\n\u001b[1;33m    \"hello\u001b[0m\n\u001b[1;37m          ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "\"hello\n",
    "world\n",
    "\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "0b546d88",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三个引号，可以包含任何文本\n",
    "# 作用：\n",
    "# 1. 保持原数据的结构，包含符号，换行等。 \n",
    "# 2. 可以用来做代码注释。\n",
    "NFU_招投标_HTML = \"\"\"\n",
    "<ul class=\"tzgg-div\" style=\"display: block;\">\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"tzgg-nr\">\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t<p class=\"tzgg-time\">\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"ztb/a400b894512f4cb7a1c55a8872a2b5f5.htm\">\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i>›</i>\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span>09-13</span>\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t</a>\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t</p>\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t<p class=\"tzgg-p\">\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"ztb/a400b894512f4cb7a1c55a8872a2b5f5.htm\">            广州南方学院智能供应链实验室建设项目竞争性磋商公告... \n",
    "    </a>\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "cf0130a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "<ul class=\"tzgg-div\" style=\"display: block;\">\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"tzgg-nr\">\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t<p class=\"tzgg-time\">\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"ztb/a400b894512f4cb7a1c55a8872a2b5f5.htm\">\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i>›</i>\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span>09-13</span>\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t</a>\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t</p>\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t<p class=\"tzgg-p\">\n",
      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"ztb/a400b894512f4cb7a1c55a8872a2b5f5.htm\">            广州南方学院智能供应链实验室建设项目竞争性磋商公告... \n",
      "    </a>\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(NFU_招投标_HTML)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "89fc79e0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "### 三个引号来代码注释\n",
    "\n",
    "import random\n",
    "import time\n",
    "\n",
    "\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "页面后缀 = \".htm\"\n",
    "page = 5\n",
    "\n",
    "\"\"\"\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)  # 字符串拼接\n",
    "    random_num = random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)\n",
    "\"\"\"\n",
    "\n",
    "print(\"hello world!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aed8e0db",
   "metadata": {},
   "source": [
    "### 2.1 字符串的运算法则\n",
    "> 1.字符串的配置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4aa0584f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'helloworld'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串的配置\n",
    "\"hello\" + \"world\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "1bfe2bd8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "近乎，Alex\n",
      "近乎，Marry\n"
     ]
    }
   ],
   "source": [
    "# 操作\n",
    "text = \"近乎，\"\n",
    "for i in [\"Alex\",\"Marry\"]:\n",
    "    result = text+i\n",
    "    print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "5faea133",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串的有序性\n",
    "地址 = \"21级网络与新媒体专业2班\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "863ea75e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "地址[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "81075e37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "地址[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "be5ccbbc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'级'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "地址[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "605a8aed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'21级网络'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "地址[0:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "85420f1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'网络与'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "地址[3:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "896379c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
